package br.xraylol.client;

import java.util.ArrayList;

import org.springframework.stereotype.Component;

import br.xraylol.bean.riot.LeagueBean;
import br.xraylol.bean.riot.LeagueItemBean;
import br.xraylol.constant.GameSubType;
import br.xraylol.constant.ServiceType;

@Component
public class LeagueClient extends GenericClient {

	public LeagueClient() {
		super(ServiceType.LEAGUE);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<LeagueBean> findLeaguesBySummoner(Long summonerId) {
		return findAll("/by-summoner/" + summonerId, ArrayList.class);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<LeagueItemBean> findLeaguesEntryBySummoner(Long summonerId) {
		return findAll("/by-summoner/" + summonerId + "/entry", ArrayList.class);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<LeagueBean> findLeaguesByTeam(String teamId) {
		return findAll("/by-team/" + teamId, ArrayList.class);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<LeagueItemBean> findLeaguesEntryByTeam(String teamId) {
		return findAll("/by-team/" + teamId + "/entry", ArrayList.class);
	}

	public LeagueBean findChallengerTierLeague(GameSubType subType) {
		return findAll("/challenger?type=" + subType.name(), LeagueBean.class, true);
	}
}
